import { Component, Emit, Prop, Watch } from 'vue-facing-decorator'
import Render from '@/render/Render'
import toNative from '@/utils/toNative'
import renderModal, {
    getModelValue,
    initModelValue,
    type FormModalDto
} from '@/components/modal/Modal'
@Component
export class BasicDataSupplementPop extends Render {
    @Prop({ default: false }) show!: boolean
    @Emit('update:show')
    showChange(val: boolean) {return val}

    @Emit('refresh')
    handleRefresh() {}

    @Watch('show', { immediate: true })
    async handleWatchShow() {
        this.formConfig.show = this.show
    }
   @Watch('formConfig.show', { immediate: true })
    handleWatchShowDialog() {
        this.showChange(this.formConfig.show)
    }
   formConfig = this.initFormConfig() as FormModalDto
   initFormConfig() {
       return {
           title: '资料补充',
           width: '450px',
           theme: 'dark',
           show: false,
           params: {
               confirmText:'确定'
           },
           items: {
               insuranceCompanyLogo: {
                   name: '资料补充',
                   element: 'textarea',
               }
           },
           complete: async () => {
               const data = getModelValue(this.formConfig)
               console.log(data, 'datadata')
               this.formConfig.show = false
               // this.showChange(false)
           },
           cancel: () => {
               this.formConfig.show = false
               // this.showChange(false)
           }
       } as FormModalDto
   }
   render() {
       return < >
           { renderModal(this.formConfig) }
       </>
   }
}

export default toNative<{}, {refresh: () => void}>(BasicDataSupplementPop)